package DimensionGui;

import java.awt.Rectangle;
import java.awt.TextArea;
import java.awt.TextField;

import org.jhotdraw.figures.AttributeFigure;
import org.jhotdraw.figures.RectangleFigure;

public class MyTextAreaWidth extends TextField implements MyTextField{
	
	// again watch this
	RectangleFigure _shape; 
	
	
	public MyTextAreaWidth(AttributeFigure shape) {
		// 
		
		// check here another iffy typecast, should only work for wall and window
		
		
		
		_shape = (RectangleFigure) shape;
		// TODO Auto-generated constructor stub
	}

	public void incrementUp(){
		
		// changes display box but no idea if shape redraws
		
				this.setText(String.valueOf((int) _shape.displayBox().getWidth()+1));
		setDimension((int) _shape.displayBox().getWidth()+1);

	}
	
	public void incrementDown(){
		this.setText(String.valueOf((int) _shape.displayBox().getWidth()-1));
		setDimension((int) _shape.displayBox().getWidth()-1);
		
	}

	@Override
	public void setDimension(int d) {
		
		Rectangle r = _shape.displayBox();
		r.setSize(d, (int)r.getHeight());
		_shape.displayBox(r);
		System.out.print("setting dimension to" + r.getSize().toString());
		// TODO Auto-generated method stub
		
	}

}
